Hello and welcome to this lecture.
In this lecture hall will be creating a function that we will use to draw the bricks to save some time.
I have already pre written the code to draw the bricks on the campus so that is from line 71 to line
85.
What this function will do the function will loop through the bricks inside the Arey and then paint
or draw them on the canvas.
All right let's go through them quickly.
The first part includes the four look you may be familiar with already from our previous lecture.
So we create the function you queer the function by type in the front.
The word function followed by the name of the function.
Again always a good idea to name your functions closely related to what the.
Do so this function is called draw in bricks and inside the parentheses we specified the Param if there's
a what it will do.
What if.
So for example to draw the bricks or indeed breaks on the come that's the function will loop through
the phone up to start here and check to see if there's any column of the column count is 0 and the column
is less than the column count.
It will add a column.
It does that each time on till the number specified column has been rushed.
Same thing for the rolls.
He checks to see if the rule the rule number is zero.
Also if the roll is less than the brick row if it is less than the brick road count it all dent add
one this plus plus means add 1 each time you go out with a loop so it will keep adding each column and
each row each time it goes to a loop until the specified number of column and rules has been achieved.
I have also created another variable here on 974 called Brick x.
Notice X is a upper case saw the value of the brick break X is source to a column.
Times.
Okay so you add the brick with bloss the pad padding plus the offset left and then form variable brick
why you add.
You multiply the brick height block brick padding blocks the brick offset top by the roll so each break.
X position is carlye worked out or calculated by the break with bloss the brake pad in multiplied by
the rule number C plus the brake offset left or right.
So the logic for the break why.
He's also similar for the brake X..
The only difference is that we use the column number and we use the rule.
Are for the brick height and we've the break of set top.
So what will happen is that every single break that is created this time the loop goes around will be
positioned in the correct place because of these values we have specified here.
The brick weaved block of brick padding it will never lead to position.
Each bridge brick.
Each time it goes or eatery's true the loop on till despose five number of rows and column has been
achieved.
The brick offset.
Top of said left is used to specify where the break his position because we the one the breaks position
to close to the edge of the canvas.
So by specifying that it come give some space before it starts painting or created the bricks on the
comeback.
All right so what's all there has been specify.
Then here we've caught the values here break see see here inside the oury are here value inside the
Green Dot kecks equal of brick X upper case and then breaks for the break c inside this Harry and then
brick are dot.
Why give you break.
Why.
So these are the individual breaks and the position of coordinates on the x and y.
So once we've got those values sorted we can now begin to draw the bricks.
He is in the context of begin part of meffert and then we use the quantities are wrecked.
No we specify the value.
Break X comma and prick Y and then were the brick with it and then break right where the context fulfils
time which is used to specify the clock.
You want to use for the brick.
So you defined the column here and the context or feel is used to do the colouring of fill the column
and then as usual all n the do I with the context dot close path taking the care that we have finished.
So one does is save all we've done so far on the javascript page to save that and then we can view in
our web browser.
Because this is linked to his team of Firewalker I'll run it directly from the script.
We need to look at our history file and run the Web.
The game.
So that's it for this lecture.
Thank you so much for your time.
Bye for now.